@pie-element/graphing 10.1.1 → 10.1.2-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/configure.js +2 -0
  2. package/controller.js +1 -0
  3. package/dist/author/configure.d.ts +26 -0
  4. package/dist/author/configure.js +208 -0
  5. package/dist/author/correct-response.d.ts +54 -0
  6. package/dist/author/correct-response.js +303 -0
  7. package/dist/author/defaults.d.ts +294 -0
  8. package/dist/author/defaults.js +415 -0
  9. package/dist/author/graphing-config.d.ts +34 -0
  10. package/dist/author/graphing-config.js +244 -0
  11. package/dist/author/index.d.ts +59 -0
  12. package/dist/author/index.js +96 -0
  13. package/dist/author/utils.d.ts +43 -0
  14. package/dist/author/utils.js +260 -0
  15. package/dist/browser/author/index.js +4480 -0
  16. package/dist/browser/author/index.js.map +1 -0
  17. package/dist/browser/container-DaIvr1Vu.js +57966 -0
  18. package/dist/browser/container-DaIvr1Vu.js.map +1 -0
  19. package/dist/browser/controller/index.js +353 -0
  20. package/dist/browser/controller/index.js.map +1 -0
  21. package/dist/browser/delivery/index.js +683 -0
  22. package/dist/browser/delivery/index.js.map +1 -0
  23. package/dist/browser/dist-BrN2xZtM.js +547 -0
  24. package/dist/browser/dist-BrN2xZtM.js.map +1 -0
  25. package/dist/browser/graphing.css +2 -0
  26. package/dist/controller/defaults.d.ts +59 -0
  27. package/dist/controller/defaults.js +61 -0
  28. package/dist/controller/index.d.ts +34 -0
  29. package/dist/controller/index.js +179 -0
  30. package/dist/controller/utils.d.ts +37 -0
  31. package/dist/controller/utils.js +111 -0
  32. package/dist/delivery/index.d.ts +21 -0
  33. package/dist/delivery/index.js +43 -0
  34. package/dist/delivery/main.d.ts +23 -0
  35. package/dist/delivery/main.js +107 -0
  36. package/dist/delivery/utils.d.ts +22 -0
  37. package/dist/graphing.css +2 -0
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.iife.d.ts +8 -0
  40. package/dist/index.iife.js +406 -0
  41. package/dist/index.js +2 -0
  42. package/dist/runtime-support.d.ts +12 -0
  43. package/dist/runtime-support.js +12 -0
  44. package/package.json +88 -21
  45. package/CHANGELOG.json +0 -652
  46. package/CHANGELOG.md +0 -2043
  47. package/LICENSE.md +0 -5
  48. package/README.md +0 -1
  49. package/configure/CHANGELOG.json +0 -382
  50. package/configure/CHANGELOG.md +0 -1834
  51. package/configure/lib/configure.js +0 -328
  52. package/configure/lib/configure.js.map +0 -1
  53. package/configure/lib/correct-response.js +0 -484
  54. package/configure/lib/correct-response.js.map +0 -1
  55. package/configure/lib/defaults.js +0 -448
  56. package/configure/lib/defaults.js.map +0 -1
  57. package/configure/lib/graphing-config.js +0 -388
  58. package/configure/lib/graphing-config.js.map +0 -1
  59. package/configure/lib/index.js +0 -173
  60. package/configure/lib/index.js.map +0 -1
  61. package/configure/lib/utils.js +0 -122
  62. package/configure/lib/utils.js.map +0 -1
  63. package/configure/package.json +0 -30
  64. package/controller/CHANGELOG.json +0 -412
  65. package/controller/CHANGELOG.md +0 -1267
  66. package/controller/lib/defaults.js +0 -64
  67. package/controller/lib/defaults.js.map +0 -1
  68. package/controller/lib/index.js +0 -459
  69. package/controller/lib/index.js.map +0 -1
  70. package/controller/lib/utils.js +0 -451
  71. package/controller/lib/utils.js.map +0 -1
  72. package/controller/package.json +0 -24
  73. package/docs/config-schema.json +0 -3164
  74. package/docs/config-schema.json.md +0 -2293
  75. package/docs/demo/config.js +0 -8
  76. package/docs/demo/generate.js +0 -200
  77. package/docs/demo/index.html +0 -1
  78. package/docs/demo/session.js +0 -20
  79. package/docs/pie-schema.json +0 -3495
  80. package/docs/pie-schema.json.md +0 -1345
  81. package/lib/index.js +0 -69
  82. package/lib/index.js.map +0 -1
  83. package/lib/main.js +0 -161
  84. package/lib/main.js.map +0 -1
  85. package/lib/utils.js +0 -24
  86. package/lib/utils.js.map +0 -1
package/configure.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from './dist/author/index.js';
2
+ export * from './dist/author/index.js';
package/controller.js ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/controller/index.js';
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/graphing/configure/src/configure.jsx
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import React from 'react';
10
+ import PropTypes from 'prop-types';
11
+ export declare class Configure extends React.Component {
12
+ static propTypes: {
13
+ onModelChanged: PropTypes.Requireable<(...args: any[]) => any>;
14
+ onConfigurationChanged: PropTypes.Requireable<(...args: any[]) => any>;
15
+ imageSupport: PropTypes.Requireable<object>;
16
+ uploadSoundSupport: PropTypes.Requireable<object>;
17
+ model: PropTypes.Validator<object>;
18
+ configuration: PropTypes.Validator<object>;
19
+ };
20
+ componentDidMount(): void;
21
+ onRationaleChange: any;
22
+ onPromptChange: any;
23
+ onTeacherInstructionsChange: any;
24
+ render(): React.JSX.Element;
25
+ }
26
+ export default Configure;
@@ -0,0 +1,208 @@
1
+ import e from "./graphing-config.js";
2
+ import t from "./correct-response.js";
3
+ import n from "react";
4
+ import r from "prop-types";
5
+ import { styled as i } from "@mui/material/styles";
6
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
7
+ import s from "debug";
8
+ import { intersection as c } from "@pie-element/shared-lodash";
9
+ import l from "@mui/material/Typography";
10
+ import { InputContainer as u, layout as d, settings as f } from "@pie-lib/config-ui";
11
+ import p from "@pie-lib/editable-html-tip-tap";
12
+ //#region src/author/configure.tsx
13
+ var { Panel: ee, toggle: m, radio: h, checkboxes: te, textField: ne, dropdown: re } = f, ie = s("@pie-element:graphing:configure"), g = i(u)(({ theme: e }) => ({
14
+ width: "100%",
15
+ paddingTop: e.spacing(2),
16
+ marginBottom: e.spacing(2)
17
+ })), ae = i(l)(({ theme: e }) => ({ marginBottom: e.spacing(2.5) })), _ = i("div")(({ theme: e }) => ({
18
+ fontSize: e.typography.fontSize - 2,
19
+ color: e.palette.error.main,
20
+ paddingTop: e.spacing(1)
21
+ })), v = class extends n.Component {
22
+ static propTypes = {
23
+ onModelChanged: r.func,
24
+ onConfigurationChanged: r.func,
25
+ imageSupport: r.object,
26
+ uploadSoundSupport: r.object,
27
+ model: r.object.isRequired,
28
+ configuration: r.object.isRequired
29
+ };
30
+ componentDidMount() {
31
+ let { configuration: e, onModelChanged: t, model: n } = this.props, { availableTools: r, title: i, graphDimensions: a } = e || {}, { arrows: o, titleEnabled: s, dimensionsEnabled: l } = n || {};
32
+ typeof o == "boolean" && (o = o ? {
33
+ left: !0,
34
+ right: !0,
35
+ up: !0,
36
+ down: !0
37
+ } : {
38
+ left: !1,
39
+ right: !1,
40
+ up: !1,
41
+ down: !1
42
+ });
43
+ let u = c(r || [], n.toolbarTools || []), d = s ?? i.enabled, f = l ?? a.enabled;
44
+ t && t({
45
+ ...n,
46
+ arrows: o,
47
+ toolbarTools: u,
48
+ titleEnabled: d,
49
+ dimensionsEnabled: f
50
+ });
51
+ }
52
+ onRationaleChange = (e) => {
53
+ let { onModelChanged: t, model: n } = this.props;
54
+ t({
55
+ ...n,
56
+ rationale: e
57
+ });
58
+ };
59
+ onPromptChange = (e) => {
60
+ let { onModelChanged: t, model: n } = this.props;
61
+ t({
62
+ ...n,
63
+ prompt: e
64
+ });
65
+ };
66
+ onTeacherInstructionsChange = (e) => {
67
+ let { onModelChanged: t, model: n } = this.props;
68
+ t({
69
+ ...n,
70
+ teacherInstructions: e
71
+ });
72
+ };
73
+ render() {
74
+ let { model: n, configuration: r, onConfigurationChanged: i, onModelChanged: s, imageSupport: c, uploadSoundSupport: l } = this.props, { arrows: u = {}, authoring: f = {}, availableTools: v = [], baseInputConfiguration: y = {}, coordinatesOnHover: b = {}, contentDimensions: x = {}, gridConfigurations: S = [], graphDimensions: C = {}, instruction: w = {}, labels: T = {}, padding: E = {}, prompt: D = {}, rationale: O = {}, scoringType: k = {}, settingsPanelDisabled: A, spellCheck: j = {}, studentInstructions: M = {}, teacherInstructions: N = {}, title: P = {}, maxImageWidth: F = {}, maxImageHeight: I = {}, withRubric: L = {}, language: R = {}, languageChoices: z = {}, mathMlOptions: B = {}, removeIncompleteTool: V = !1 } = r || {}, { errors: H = {}, extraCSSRules: U, labelsEnabled: W, dimensionsEnabled: G, promptEnabled: K, rationaleEnabled: oe, spellCheckEnabled: q, teacherInstructionsEnabled: se, titleEnabled: ce } = n || {}, { prompt: J, rationale: Y, teacherInstructions: X } = H || {};
75
+ ie("[render] model", n);
76
+ let Z = F && F.prompt, Q = I && I.prompt, le = {
77
+ top: T.top,
78
+ right: T.right,
79
+ bottom: T.bottom,
80
+ left: T.left
81
+ }, ue = {
82
+ arrows: u.settings && te(u.label, {
83
+ left: u.left,
84
+ right: u.right,
85
+ up: u.up,
86
+ down: u.down
87
+ }),
88
+ titleEnabled: P.settings && m(P.label),
89
+ padding: E.settings && m(E.label),
90
+ labelsEnabled: T.settings && m(T.label),
91
+ "language.enabled": R.settings && m(R.label, !0),
92
+ language: R.settings && R.enabled && re(z.label, z.options),
93
+ dimensionsEnabled: C.settings && m(C.label),
94
+ coordinatesOnHover: b.settings && m(b.label)
95
+ }, de = {
96
+ "authoring.enabled": f.settings && m(f.label, !0),
97
+ teacherInstructionsEnabled: N.settings && m(N.label),
98
+ studentInstructionsEnabled: M.settings && m(M.label),
99
+ promptEnabled: D.settings && m(D.label),
100
+ rationaleEnabled: O.settings && m(O.label),
101
+ spellCheckEnabled: j.settings && m(j.label),
102
+ scoringType: k.settings && h(k.label, ["dichotomous", "partial scoring"]),
103
+ rubricEnabled: L?.settings && m(L?.label),
104
+ instruction: w.settings && ne(w.label)
105
+ }, $ = (e = {}) => ({
106
+ ...y,
107
+ ...e
108
+ });
109
+ return /* @__PURE__ */ o(d.ConfigLayout, {
110
+ extraCSSRules: U,
111
+ dimensions: x,
112
+ hideSettings: A,
113
+ settings: /* @__PURE__ */ a(ee, {
114
+ model: n,
115
+ configuration: r,
116
+ onChangeModel: s,
117
+ onChangeConfiguration: i,
118
+ groups: {
119
+ Settings: ue,
120
+ Properties: de
121
+ }
122
+ }),
123
+ children: [
124
+ /* @__PURE__ */ a(ae, {
125
+ component: "div",
126
+ variant: "body1",
127
+ children: w?.label || ""
128
+ }),
129
+ se && /* @__PURE__ */ o(g, {
130
+ label: N.label,
131
+ children: [/* @__PURE__ */ a(p, {
132
+ markup: n.teacherInstructions || "",
133
+ onChange: this.onTeacherInstructionsChange,
134
+ imageSupport: c,
135
+ error: X,
136
+ nonEmpty: !1,
137
+ pluginProps: $(N?.inputConfiguration),
138
+ spellCheck: q,
139
+ maxImageWidth: F && F.teacherInstructions || Z,
140
+ maxImageHeight: I && I.teacherInstructions || Q,
141
+ uploadSoundSupport: l,
142
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
143
+ mathMlOptions: B
144
+ }), X && /* @__PURE__ */ a(_, { children: X })]
145
+ }),
146
+ K && /* @__PURE__ */ o(g, {
147
+ label: D.label,
148
+ children: [/* @__PURE__ */ a(p, {
149
+ markup: n.prompt,
150
+ onChange: this.onPromptChange,
151
+ imageSupport: c,
152
+ error: J,
153
+ nonEmpty: !1,
154
+ spellCheck: q,
155
+ pluginProps: $(D?.inputConfiguration),
156
+ disableUnderline: !0,
157
+ maxImageWidth: Z,
158
+ maxImageHeight: Q,
159
+ uploadSoundSupport: l,
160
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
161
+ mathMlOptions: B
162
+ }), J && /* @__PURE__ */ a(_, { children: J })]
163
+ }),
164
+ /* @__PURE__ */ a(e, {
165
+ authoring: f,
166
+ availableTools: v,
167
+ gridConfigurations: S,
168
+ graphDimensions: C,
169
+ labelsPlaceholders: le,
170
+ model: n,
171
+ showLabels: W,
172
+ dimensionsEnabled: G,
173
+ showTitle: ce,
174
+ titlePlaceholder: P.placeholder,
175
+ onChange: this.props.onModelChanged,
176
+ mathMlOptions: B,
177
+ removeIncompleteTool: V
178
+ }),
179
+ /* @__PURE__ */ a(t, {
180
+ availableTools: v,
181
+ errors: H,
182
+ model: n,
183
+ onChange: this.props.onModelChanged,
184
+ mathMlOptions: B,
185
+ removeIncompleteTool: V
186
+ }),
187
+ oe && /* @__PURE__ */ o(g, {
188
+ label: O.label || "Rationale",
189
+ children: [/* @__PURE__ */ a(p, {
190
+ markup: n.rationale || "",
191
+ onChange: this.onRationaleChange,
192
+ imageSupport: c,
193
+ error: Y,
194
+ spellCheck: q,
195
+ pluginProps: $(O?.inputConfiguration),
196
+ maxImageWidth: F && F.rationale || Z,
197
+ maxImageHeight: I && I.rationale || Q,
198
+ uploadSoundSupport: l,
199
+ languageCharactersProps: [{ language: "spanish" }, { language: "special" }],
200
+ mathMlOptions: B
201
+ }), Y && /* @__PURE__ */ a(_, { children: Y })]
202
+ })
203
+ ]
204
+ });
205
+ }
206
+ };
207
+ //#endregion
208
+ export { v as default };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @synced-from pie-elements/packages/graphing/configure/src/correct-response.jsx
3
+ * @auto-generated
4
+ *
5
+ * This file is automatically synced from pie-elements and converted to TypeScript.
6
+ * Manual edits will be overwritten on next sync.
7
+ * To make changes, edit the upstream JavaScript file and run sync again.
8
+ */
9
+ import * as React from 'react';
10
+ import PropTypes from 'prop-types';
11
+ export declare const Tools: {
12
+ ({ availableTools, defaultTool, hasErrors, toolbarTools, toggleToolBarTool, onDefaultToolChange, }: {
13
+ availableTools: any;
14
+ defaultTool: any;
15
+ hasErrors: any;
16
+ toolbarTools: any;
17
+ toggleToolBarTool: any;
18
+ onDefaultToolChange: any;
19
+ }): React.JSX.Element;
20
+ propTypes: {
21
+ toolbarTools: PropTypes.Requireable<(string | null | undefined)[]>;
22
+ toggleToolBarTool: PropTypes.Requireable<(...args: any[]) => any>;
23
+ availableTools: PropTypes.Requireable<any[]>;
24
+ defaultTool: PropTypes.Requireable<string>;
25
+ hasErrors: PropTypes.Requireable<number>;
26
+ onDefaultToolChange: PropTypes.Requireable<(...args: any[]) => any>;
27
+ };
28
+ };
29
+ export declare class CorrectResponse extends React.Component {
30
+ static propTypes: {
31
+ availableTools: PropTypes.Requireable<any[]>;
32
+ errors: PropTypes.Requireable<object>;
33
+ model: PropTypes.Validator<object>;
34
+ onChange: PropTypes.Validator<(...args: any[]) => any>;
35
+ toolbarTools: PropTypes.Requireable<unknown[]>;
36
+ };
37
+ state: {
38
+ dialog: {
39
+ open: boolean;
40
+ };
41
+ };
42
+ componentDidMount(): void;
43
+ handleAlertDialog: (open: any, callback: any) => void;
44
+ changeMarks: any;
45
+ filterMarks: any;
46
+ changeToolbarTools: any;
47
+ updateModel: any;
48
+ toggleToolBarTool: any;
49
+ onDefaultToolChange: any;
50
+ addAlternateResponse: any;
51
+ deleteAlternateResponse: any;
52
+ render(): React.JSX.Element;
53
+ }
54
+ export default CorrectResponse;
@@ -0,0 +1,303 @@
1
+ import * as e from "react";
2
+ import { renderMath as t } from "@pie-element/shared-math-rendering-mathjax";
3
+ import n from "prop-types";
4
+ import { styled as r } from "@mui/material/styles";
5
+ import { GraphContainer as i } from "@pie-lib/graphing";
6
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
7
+ import { isEqual as s, set as c } from "@pie-element/shared-lodash";
8
+ import { AlertDialog as l } from "@pie-lib/config-ui";
9
+ import { MenuItem as u, Select as d, Tooltip as f, Typography as p } from "@mui/material";
10
+ import m from "react-dom";
11
+ import h from "@mui/icons-material/Delete";
12
+ import g from "@mui/icons-material/Info";
13
+ //#region src/author/correct-response.tsx
14
+ var _ = "#D5D5D5", v = "#AAAAAA", y = r("div")({ color: v }), b = r("div")(({ theme: e }) => ({
15
+ margin: `${e.spacing(2.5)} 0`,
16
+ cursor: "pointer",
17
+ background: e.palette.grey[200],
18
+ padding: e.spacing(1.5),
19
+ width: "fit-content",
20
+ borderRadius: "4px",
21
+ "&:hover": { background: _ }
22
+ })), x = r("div")(({ theme: e }) => ({
23
+ marginTop: e.spacing(1),
24
+ display: "flex",
25
+ flexWrap: "wrap"
26
+ })), S = r("div")(({ theme: e }) => ({
27
+ cursor: "pointer",
28
+ margin: e.spacing(1),
29
+ padding: e.spacing(1),
30
+ border: `2px solid ${e.palette.common.white}`,
31
+ textTransform: "capitalize",
32
+ "&:hover": { color: e.palette.grey[800] }
33
+ })), C = r(S)({
34
+ background: _,
35
+ border: `2px solid ${v}`
36
+ }), w = r("div")(({ theme: e }) => ({
37
+ display: "flex",
38
+ alignItems: "center",
39
+ marginTop: e.spacing(2.5)
40
+ })), T = r("div")(({ theme: e }) => ({
41
+ marginLeft: "6px",
42
+ color: e.palette.grey[600],
43
+ "&:hover": {
44
+ cursor: "pointer",
45
+ color: e.palette.common.black
46
+ }
47
+ })), E = r("div")(({ theme: e }) => ({ marginBottom: e.spacing(.5) })), D = r(({ className: e, ...t }) => /* @__PURE__ */ a(f, {
48
+ ...t,
49
+ classes: { tooltip: e }
50
+ }))(({ theme: e }) => ({ "& .MuiTooltip-tooltip": {
51
+ fontSize: e.typography.fontSize - 2,
52
+ whiteSpace: "pre",
53
+ maxWidth: "500px"
54
+ } })), O = r(p)(({ theme: e }) => ({
55
+ marginTop: e.spacing(1.5),
56
+ marginBottom: e.spacing(1)
57
+ })), k = r("div")({
58
+ display: "flex",
59
+ alignItems: "center",
60
+ justifyContent: "space-between"
61
+ }), A = r("div")({
62
+ display: "flex",
63
+ alignItems: "center",
64
+ width: "300px"
65
+ }), j = r(d)(({ theme: e }) => ({
66
+ marginLeft: e.spacing(1),
67
+ textTransform: "uppercase",
68
+ color: e.palette.grey[800]
69
+ })), M = r(u)({ textTransform: "uppercase" }), N = r("div")(({ theme: e }) => ({
70
+ fontSize: e.typography.fontSize - 2,
71
+ color: e.palette.error.main,
72
+ marginTop: e.spacing(1)
73
+ })), P = ({ availableTools: e, defaultTool: t, hasErrors: n, toolbarTools: r, toggleToolBarTool: i, onDefaultToolChange: s }) => {
74
+ let c = e || [], l = c.includes("label"), u = (r || []).filter((e) => e !== "label");
75
+ return l && (c = [...c.filter((e) => e !== "label"), "label"]), /* @__PURE__ */ o(y, { children: [/* @__PURE__ */ o(k, { children: [/* @__PURE__ */ a("span", { children: "GRAPHING TOOLS" }), u.length > 0 && /* @__PURE__ */ o(A, { children: [/* @__PURE__ */ a("span", { children: "Default graphing tool:" }), /* @__PURE__ */ a(j, {
76
+ variant: "standard",
77
+ onChange: s,
78
+ value: t,
79
+ disableUnderline: !0,
80
+ MenuProps: { transitionDuration: {
81
+ enter: 225,
82
+ exit: 195
83
+ } },
84
+ children: u.map((e, t) => /* @__PURE__ */ a(M, {
85
+ value: e,
86
+ children: e
87
+ }, t))
88
+ })] })] }), /* @__PURE__ */ a(x, { children: c.map((e) => /* @__PURE__ */ a(r.find((t) => t === e) ? C : S, {
89
+ style: { ...n && e !== "label" && { color: "red" } },
90
+ onClick: () => i(e),
91
+ children: e.toUpperCase()
92
+ }, e)) })] });
93
+ };
94
+ P.propTypes = {
95
+ toolbarTools: n.arrayOf(n.string),
96
+ toggleToolBarTool: n.func,
97
+ availableTools: n.array,
98
+ defaultTool: n.string,
99
+ hasErrors: n.number,
100
+ onDefaultToolChange: n.func
101
+ };
102
+ var F = class extends e.Component {
103
+ static propTypes = {
104
+ availableTools: n.array,
105
+ errors: n.object,
106
+ model: n.object.isRequired,
107
+ onChange: n.func.isRequired,
108
+ toolbarTools: n.arrayOf(n.String)
109
+ };
110
+ state = { dialog: { open: !1 } };
111
+ componentDidMount() {
112
+ try {
113
+ t(m.findDOMNode(this));
114
+ } catch {
115
+ console.error("DOM not mounted");
116
+ }
117
+ }
118
+ handleAlertDialog = (e, t) => this.setState({ dialog: { open: e } }, t);
119
+ changeMarks = (e, t) => {
120
+ let { model: n, onChange: r } = this.props;
121
+ c(n, `answers.${e}.marks`, t), r(n);
122
+ };
123
+ filterMarks = (e) => {
124
+ let { model: { answers: t } } = this.props;
125
+ return Object.entries(t || {}).reduce((t, [n, r]) => (t[n] = {
126
+ ...r,
127
+ marks: (r.marks || []).filter((t) => t.type !== e)
128
+ }, t), {});
129
+ };
130
+ changeToolbarTools = (e) => {
131
+ let { model: t, onChange: n } = this.props;
132
+ t.toolbarTools = e, n(t);
133
+ };
134
+ updateModel = (e) => {
135
+ let { model: t, onChange: n } = this.props;
136
+ n({
137
+ ...t,
138
+ ...e
139
+ });
140
+ };
141
+ toggleToolBarTool = (e) => {
142
+ let { model: { defaultTool: t, toolbarTools: n, answers: r = {} } } = this.props, i = [...n], a = t, o = n.findIndex((t) => e === t);
143
+ if (o >= 0) {
144
+ let n = this.filterMarks(e);
145
+ if (i.splice(o, 1), e === t) {
146
+ let e = (i || []).filter((e) => e !== "label");
147
+ a = e.length && e[0] || "";
148
+ }
149
+ if (!s(r, n)) {
150
+ this.setState({ dialog: {
151
+ open: !0,
152
+ title: "Warning",
153
+ text: `Correct answer includes one or more ${e} objects and all of them will be deleted.`,
154
+ onConfirm: () => this.handleAlertDialog(!1, this.updateModel({
155
+ toolbarTools: i,
156
+ answers: n,
157
+ defaultTool: a
158
+ })),
159
+ onClose: () => this.handleAlertDialog(!1)
160
+ } });
161
+ return;
162
+ }
163
+ } else i.push(e), t === "" && e !== "label" && (a = e);
164
+ this.updateModel({
165
+ toolbarTools: i,
166
+ defaultTool: a
167
+ });
168
+ };
169
+ onDefaultToolChange = (e) => {
170
+ let { value: t } = e.target;
171
+ this.updateModel({ defaultTool: t });
172
+ };
173
+ addAlternateResponse = () => {
174
+ let { model: e, onChange: t } = this.props, { answers: n } = e || {}, r = Object.keys(n || {});
175
+ c(e, `answers.${`alternate${r.length}`}`, {
176
+ name: `Alternate ${r.length}`,
177
+ marks: []
178
+ }), t(e);
179
+ };
180
+ deleteAlternateResponse = (e, t) => {
181
+ let { model: n, onChange: r } = this.props, { answers: i } = n || {}, { marks: a = [], name: o } = t || {}, s = () => {
182
+ delete i[e];
183
+ let t = Object.entries(i).reduce((e, t, n) => {
184
+ let [r, i] = t;
185
+ return r === "correctAnswer" ? {
186
+ ...e,
187
+ [r]: i
188
+ } : {
189
+ ...e,
190
+ ["alternate" + n]: {
191
+ ...i,
192
+ name: `Alternate ${n}`
193
+ }
194
+ };
195
+ }, {});
196
+ r({
197
+ ...n,
198
+ answers: t
199
+ });
200
+ };
201
+ if (a.length) {
202
+ this.setState({ dialog: {
203
+ open: !0,
204
+ title: "Warning",
205
+ text: `${o} includes one or more shapes and the entire response will be deleted.`,
206
+ onConfirm: () => this.handleAlertDialog(!1, s),
207
+ onClose: () => this.handleAlertDialog(!1)
208
+ } });
209
+ return;
210
+ }
211
+ s();
212
+ };
213
+ render() {
214
+ let { availableTools: t, errors: n, model: r, mathMlOptions: s = {}, removeIncompleteTool: c } = this.props, { dialog: u } = this.state, { answers: d = {}, arrows: f, backgroundMarks: m, coordinatesOnHover: _, defaultTool: v, domain: y, graph: x = {}, labels: S, labelsEnabled: C, range: k, title: A, titleEnabled: j, toolbarTools: M } = r || {}, { correctAnswerErrors: F = {}, toolbarToolsError: I } = n || {};
215
+ return /* @__PURE__ */ o("div", { children: [
216
+ /* @__PURE__ */ a(p, {
217
+ component: "div",
218
+ variant: "h6",
219
+ children: "Define Tool Set and Correct Response"
220
+ }),
221
+ /* @__PURE__ */ a(O, {
222
+ component: "div",
223
+ variant: "body1",
224
+ children: "Use this interface to choose which graphing tools students will be able to use, and to define the correct answer"
225
+ }),
226
+ /* @__PURE__ */ a(P, {
227
+ availableTools: t,
228
+ defaultTool: v,
229
+ hasErrors: !!I,
230
+ onDefaultToolChange: this.onDefaultToolChange,
231
+ toggleToolBarTool: this.toggleToolBarTool,
232
+ toolbarTools: M
233
+ }),
234
+ I && /* @__PURE__ */ a(N, { children: I }),
235
+ Object.entries(d || {}).map(([t, n]) => {
236
+ let { marks: r = [], name: l } = n || {};
237
+ return /* @__PURE__ */ o(e.Fragment, { children: [
238
+ /* @__PURE__ */ o(w, { children: [
239
+ /* @__PURE__ */ a(E, { children: l }),
240
+ t === "correctAnswer" && /* @__PURE__ */ a(D, {
241
+ disableFocusListener: !0,
242
+ disableTouchListener: !0,
243
+ placement: "right",
244
+ title: "At least 1 graph object should be defined.",
245
+ children: /* @__PURE__ */ a(g, {
246
+ fontSize: "small",
247
+ color: "primary",
248
+ style: {
249
+ marginLeft: "8px",
250
+ marginBottom: "auto"
251
+ }
252
+ })
253
+ }),
254
+ t !== "correctAnswer" && /* @__PURE__ */ a(T, {
255
+ onClick: () => this.deleteAlternateResponse(t, n),
256
+ children: /* @__PURE__ */ a(h, {})
257
+ })
258
+ ] }),
259
+ /* @__PURE__ */ a(i, {
260
+ style: F[t] && { border: "2px solid red" },
261
+ axesSettings: { includeArrows: f },
262
+ backgroundMarks: m.filter((e) => !e.building),
263
+ coordinatesOnHover: _,
264
+ disabledLabels: !0,
265
+ disabledTitle: !0,
266
+ domain: y,
267
+ draggableTools: t === "correctAnswer",
268
+ labels: S,
269
+ marks: r,
270
+ onChangeMarks: (e) => this.changeMarks(t, e),
271
+ range: k,
272
+ showLabels: C,
273
+ showTitle: j,
274
+ size: {
275
+ width: x.width,
276
+ height: x.height
277
+ },
278
+ title: A,
279
+ toolbarTools: M,
280
+ onChangeTools: (e) => this.updateModel({ toolbarTools: e }),
281
+ mathMlOptions: s,
282
+ removeIncompleteTool: c,
283
+ limitLabeling: !0
284
+ }),
285
+ F[t] && /* @__PURE__ */ a(N, { children: F[t] })
286
+ ] }, `correct-response-graph-${l}`);
287
+ }),
288
+ /* @__PURE__ */ a(b, {
289
+ onClick: this.addAlternateResponse,
290
+ children: "ADD ALTERNATE"
291
+ }),
292
+ /* @__PURE__ */ a(l, {
293
+ open: u.open,
294
+ title: u.title,
295
+ text: u.text,
296
+ onClose: u.onClose,
297
+ onConfirm: u.onConfirm
298
+ })
299
+ ] });
300
+ }
301
+ };
302
+ //#endregion
303
+ export { F as default };